pub(crate) fn xml_item(tag: &str, value: &str) -> String {
    format!(
        "<{}>{}</{}>",
        tag,
        value
            .replace("&", "&amp;")
            .replace("<", "&lt;")
            .replace(">", "&gt;")
            .replace("\"", "&qot;"),
        tag
    )
}

pub(crate) fn format_xml(code: &str) -> anyhow::Result<String> {
    let options = markup_fmt::config::FormatOptions::default();
    markup_fmt::format_text(code, markup_fmt::Language::Xml, &options, |code, _| {
        Ok::<_, std::convert::Infallible>(code.into())
    })
    .map_err(|err| anyhow::anyhow!("format xml code fail:{err}"))
}
